package com.travel.stock.controller;

import java.util.Arrays;
import java.util.Map;

import com.travel.common.to.StockSkuTo;
import com.travel.stock.entity.StockSkuEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import com.travel.stock.service.StockSkuService;
import com.travel.common.utils.PageUtils;
import com.travel.common.utils.R;



/**
 * 商品库存
 *
 * @author lxw
 * @email lxw@gmail.com
 * @date 2024-01-15 09:17:51
 */
@RestController
@RequestMapping("stock/stocksku")
public class StockSkuController {
    @Autowired
    private StockSkuService stockSkuService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("stock:stocksku:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = stockSkuService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("stock:stocksku:info")
    public R info(@PathVariable("id") Long id){
		StockSkuEntity stockSku = stockSkuService.getById(id);

        return R.ok().put("stockSku", stockSku);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("stock:stocksku:save")
    public R save(@RequestBody StockSkuEntity stockSku){
		stockSkuService.save(stockSku);

        return R.ok();
    }

    /**
     * 保存sku库存信息
     */
    @PostMapping("/saveSkuStock")
    public R saveSkuStock(@RequestBody StockSkuTo stockSkuTo){
        stockSkuService.saveSkuStock(stockSkuTo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("stock:stocksku:update")
    public R update(@RequestBody StockSkuEntity stockSku){
		stockSkuService.updateById(stockSku);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("stock:stocksku:delete")
    public R delete(@RequestBody Long[] ids){
		stockSkuService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
